home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
HENSA
/
MISC
/
SHELL.ARC
/
Shell
/
Sources
/
c
/
BlockRect
< prev
next >
Wrap
Text File
|
1994-06-25
|
2KB
|
107 lines
#include "DeskLib:WimpSWIs.h"
#include "DeskLib:GFX.h"
#include "Shell.BlockRct.h"
#include "Shell.Extra.h"
#include "Shell.SafeAlloc.h"
typedef struct {
Shell_GeneralBlockRectFn fn;
void *reference;
int width, height;
int maxx, maxy;
}
Shell_GeneralBlockRectInfo;
static void Shell_GeneralBlockRectRedrawer(
Shell_convertpoint convert,
wimp_point rectsize,
void *reference,
const wimp_rect *redrawrect
)
{
wimp_rect rect = *redrawrect;
Shell_GeneralBlockRectInfo *info;
info = (Shell_GeneralBlockRectInfo *) reference;
Shell_ConvertToSubRect2( &rect, rectsize);
rect.min.x /= info->width;
rect.max.x /= info->width;
rect.min.y /= info->height;
rect.max.y /= info->height;
{ int i, j;
for ( i=rect.min.x; i<=rect.max.x; i++) {
int x = i*info->width;
for ( j=rect.min.y; j<=rect.max.y; j++) {
int col = info->fn( i, j, info->maxx, info->maxy, info->reference);
Wimp_SetColour( col);
Shell_RectangleFill3(
x, j*info->height,
info->width - Shell_PIXELXSIZE,
info->height - Shell_PIXELYSIZE,
convert
);
}
}
}
return;
}
Shell_rectblock *Shell_AddGeneralBlockRect(
Shell_windblock *wind,
int x,
int y,
int maxx,
int maxy,
int width,
int height,
Shell_GeneralBlockRectFn fn,
const void *reference
)
{
wimp_rect rect;
Shell_GeneralBlockRectInfo *info;
Shell_rectblock *r;
info = Shell_SafeMalloc( sizeof( Shell_GeneralBlockRectInfo));
info->fn = fn;
info->width = width;
info->height = height;
info->maxx = maxx;
info->maxy = maxy;
info->reference = (void *) reference;
rect.max.x = x+maxx*width;
rect.max.y = y+maxy*height;
rect.min.x = x;
rect.min.y = y;
r = Shell_AddRectangle( wind, &rect, Shell_GeneralBlockRectRedrawer, (void *) info);
/* Could call Shell_MakeRectIcon here to give the blockrect a border. */
/* However, I sometimes want to graba blockrect to put into a paper and */
/* it looks better without the border on paper. */
return r;
}